package hardwareToSQL.pruningAlgorithm;


public class PruningAverage implements Pruning{

	private int numOfValuesForAverage;
	private double[]storageBuffer;
	private double sum;
	
	public PruningAverage(int numOfValuesForAverage){
		
		this.numOfValuesForAverage = numOfValuesForAverage;
		
		storageBuffer = new double[numOfValuesForAverage];
		for(int i = 0; i< numOfValuesForAverage; i++){
			storageBuffer[i] = numOfValuesForAverage;
		}
	}
	
	
	public void insertValue(double value){
		for(int i = 0; i< numOfValuesForAverage-1; i++){
			storageBuffer[i] = storageBuffer[i+1];
		}
		storageBuffer[numOfValuesForAverage-1] = value;
	}
	
	
	public double returnValue(){
		for(int i = 0; i< numOfValuesForAverage; i++){
			sum += storageBuffer[i];
		}
		
		return (sum/numOfValuesForAverage);
		
	}
	
}
